VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "FastMid"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'***************************************************************
' (c) Copyright 2000 Matthew J. Curland
'
' This file is from the CD-ROM accompanying the book:
' Advanced Visual Basic 6: Power Techniques for Everyday Programs
'   Author: Matthew Curland
'   Published by: Addison-Wesley, July 2000
'   ISBN: 0-201-70712-8
'   http://www.PowerVB.com
'
' You are entitled to license free distribution of any application
'   that uses this file if you own a copy of the book, or if you
'   have obtained the file from a source approved by the author. You
'   may redistribute this file only with express written permission
'   of the author.
'
' This file depends on:
'   References:
'     VBoostTypes6.olb (VBoost Object Types (6.0))
'     VBoost6.Dll (VBoost Object Implementation (6.0)) (optional)
'   Files:
'     ArrayOwner.bas or ArrayOwnerIgnoreOnly.bas
'     VBoost.Bas (optional)
'   Minimal VBoost conditionals:
'     VBOOST_INTERNAL = 1 : VBOOST_CUSTOM = 1
'   Conditional Compilation Values:
'     NOVBOOST = 1 'Removes VBoost dependency
'
' This file is discussed in Chapters 14.
'***************************************************************
Option Explicit

Private Type OwnedInteger
    Owner As ArrayOwner
    pSA() As Integer
End Type
Private m_FullString As OwnedInteger
Private m_SingleChar As OwnedInteger

Public Function GetMidString(FullString As String) As String
    GetMidString = String$(1, 0)
    m_SingleChar.Owner.SA.pvData = StrPtr(GetMidString)
    With m_FullString.Owner.SA
        .pvData = StrPtr(FullString)
        .cElements = Len(FullString)
    End With
End Function
Public Sub SetMidPosition(ByVal Index As Long)
    m_SingleChar.pSA(0) = m_FullString.pSA(Index)
End Sub
Private Sub Class_Initialize()
    With m_FullString
        InitArrayOwner .Owner, 2, 0
        'FastMid is 1-based to map directly to the Mid$ function
        .Owner.SA.lLbound = 1
    End With
    InitArrayOwner m_SingleChar.Owner, 2, 0
End Sub
